﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using FCNS.KeepMoneyLibrary.Data;

namespace FCNS.KeepMoney.Forms
{
    public partial class DateForm : Form
    {
        public DateForm()
        {
            InitializeComponent();
        }

        GtdEntryField task = null;

        public DateTime SelectedDate
        {
            get
            {
                return monthCalendar1.SelectionEnd;
            }
            set { monthCalendar1.SelectionEnd = value; }
        }

        private void OnDateChanged(object sender, DateRangeEventArgs e)
        {
            task.EndTime = monthCalendar1.SelectionEnd;
            this.Close();
        }

        private void OnFormLeave(object sender, EventArgs e)
        {
            this.Close();
        }

        private void DateForm_Load(object sender, EventArgs e)
        {
            this.Size = monthCalendar1.Size;
        }

        public void Init(GtdEntryField task)
        {
            this.task = task;
            monthCalendar1.SelectionStart = task.StartTime;
            monthCalendar1.SelectionEnd = task.EndTime;
        }

        private void monthCalendar1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
                this.Close();
        }
    }
}

